home *** CD-ROM | disk | FTP | other *** search
/ The Arsenal Files 8 / The Arsenal Files Collection #8 (Arsenal Computer) (1996).ISO / prg_casm / snip9611.zip / SCRNPICK.C < prev    next >
C/C++ Source or Header  |  1996-11-24  |  2KB  |  63 lines

  1. /* +++Date last modified: 02-Nov-1995 */
  2.  
  3. /* program:    mousword.c
  4.  * programmer: Ray L. McVay
  5.  * date:       20 Oct 1988
  6.  * modified:   15 Feb 93 by Bob Stout to use Bob Jarvis' MOUSE.H and MOUSE.C
  7.  *
  8.  * Demonstration of picking "words" off a text mode PC screen using a mouse.
  9.  * Submitted to the C_ECHO and placed in the public domain, 7 Jun 1992.
  10.  */
  11.  
  12. #include <stdio.h>
  13. #include <stdlib.h>
  14. #include "mouse.h"
  15. #include "scrnmacs.h"
  16.  
  17. char word[80];
  18. unsigned FAR *scrn;
  19.  
  20. void getword(char *, int, int);
  21.  
  22. main(void)
  23. {
  24.       int done, b, x, y;
  25.  
  26.       scrn = SCRBUFF;
  27.       ms_reset(&b); /* reset */
  28.       ms_show_cursor();
  29.       for (done = 0; !done; )
  30.       {
  31.             b = ms_get_mouse_pos(&x, &y);
  32.             if (b == 1)
  33.             {
  34.                   ms_hide_cursor();
  35.                   getword(word, x/8, y/8);
  36.                   do
  37.                   {
  38.                         b = ms_get_mouse_pos(&x, &y);
  39.                   } while (b);
  40.                   if (*word)
  41.                         printf("{%s}\n", word);
  42.                   ms_show_cursor();
  43.             }
  44.             else if (b > 1)
  45.                   done = 1;
  46.       }
  47.       ms_reset(&b);
  48.       return 0;
  49. }
  50.  
  51. void getword(char *w, int x, int y)
  52. {
  53.       int txs, txe, ci;
  54.     
  55.       for (txs = x; (txs >= 0) && ((scrn[80 * y + txs] & 255) != 32); txs--)
  56.             scrn[80 * y + txs] = (scrn[80 * y + txs] & 255) | 0x7000;
  57.       for (txe = x; (txe < 80) && ((scrn[80 * y + txe] & 255) != 32); txe++)
  58.             scrn[80 * y + txe] = (scrn[80 * y + txe] & 255) | 0x7000;
  59.       for (ci = txs + 1; ci < txe; ci++)
  60.             *w++ = (char)scrn[80 * y + ci];
  61.       *w = 0;
  62. }
  63.